package com.softeem.music.controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.softeem.music.comm.R;
import com.softeem.music.entity.MusicList;
import com.softeem.music.service.MusicListService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.Parameters;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 歌单控制层:歌单列表、歌单详情、歌单添加、歌单修改、歌单删除
 */
@Tag(name = "歌单管理")
@RestController
public class MusicListController {
    @Autowired
    private MusicListService musicListService;
    @Operation(summary = "歌单列表",description = "分页查询歌单列表")
    @Parameters({
            @Parameter(name = "page",description = "页码"),
            @Parameter(name = "limit",description = "数据条数")
    })
    @GetMapping("/musicList/list")
    public R list(@RequestParam (defaultValue = "1") Integer page, @RequestParam (defaultValue = "6") Integer limit){
        IPage<MusicList> iPage = new Page<>(page,limit);
        List<MusicList> list = musicListService.list(iPage);
        return R.success().setData(list);
    }
}
